package com.wtg.client.control;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.wtg.client.api.res.ListDataRes;
import com.wtg.client.bean.Product;
import com.wtg.client.util.JwtUtil;

@RestController
@RequestMapping("product")
public class ProductControl {
	
	@RequestMapping("get/{id}")
	public ListDataRes<Product> getProduct(@PathVariable("id") String id,HttpServletRequest request) {
		String jwt = request.getHeader("Authorization");
		try {
			System.out.println(JwtUtil.parseJWT(jwt));
		} catch (Exception e) {
			e.printStackTrace();
		}
		//省略业务过程
		Product product = new Product(id, "数码相机", 10);
		ListDataRes<Product> dataRes = new ListDataRes<>();
		dataRes.setMsg("查询成功");
		dataRes.setCode("000000");
		dataRes.getList().add(product);
		return dataRes;
	}

}
